package com.fms.kccc.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.blobstore.BlobKey;
import com.google.appengine.api.blobstore.BlobstoreService;
import com.google.appengine.api.blobstore.BlobstoreServiceFactory;

public class ImageServlet extends BaseServlet{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static final String PARAMETER_IMAGE = "imageid";
	private BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
	

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException, ServletException {
		// TODO Auto-generated method stub
		String imageID = getParameter(req, PARAMETER_IMAGE);
		BlobKey blobKey = new BlobKey(imageID);
        blobstoreService.serve(blobKey, resp);
	}
}
